import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;


public class SWTKeyTest {

    public static void main(String[] args) {
        Display display = new Display();
        Shell shell = new Shell(display,SWT.MIN|SWT.CLOSE);
        shell.setSize(200,50);
        shell.addKeyListener(new KeyListener() {
			
			@Override
			public void keyReleased(KeyEvent arg0) {
				System.out.println(">>>> " + arg0.character);
			}
			
			@Override
			public void keyPressed(KeyEvent arg0) {
				char ch = arg0.character;
				System.out.println("---- " + ch);
			}
		});
        shell.open();
        while(!shell.isDisposed()) {
            if(!display.readAndDispatch()) display.sleep();
        }
        display.dispose();
    }

}